package com.seed.uaa.util;

import cn.hutool.core.util.StrUtil;
import com.seed.core.pojo.Const;

import java.util.ArrayList;
import java.util.List;

public class AncestorUtil {
    public static List<String> getAncestorCodeList(String code) {
        List<String> ret = new ArrayList<>();

        if(StrUtil.isBlank(code)) return ret;

        char separator = Const.CODE_SEPARATOR;
        String tmp = code;
        int pos = tmp.lastIndexOf(separator);
        while (pos > 0) {
            tmp = tmp.substring(0, tmp.lastIndexOf(separator));
            ret.add(tmp);
            pos = tmp.lastIndexOf(separator);
        }

        return ret;
    }
}
